/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.Metodos;

import com.myapp.model.usuarios.Usuarios;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author jaime
 */
public class EncripPassword {
    /**
     * Metodo para encriptar el password  
     * @param password password sin encriptar
     * @return password encriptado
     */
    public String encripPassword(String password) throws NoSuchAlgorithmException{
        String clear = password;

        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] b = md.digest(clear.getBytes());

        int size = b.length;

        StringBuffer h = new StringBuffer(size);
        for (int i = 0; i < size; i++) {
            int u = b[i] & 255;
            if (u < 16) {
                h.append("0" + Integer.toHexString(u));
            } else {
                h.append(Integer.toHexString(u));
            }
        }
        password=h.toString();

        return password;
    }
}
